package HtServer.GrpcDataSet;
import grpc.htsoft.DataBase.*;
import io.grpc.stub.StreamObserver;

public class DataSetImpl extends DBGreeterGrpc.DBGreeterImplBase {

    @Override
    public void getRow(DBInfo request, StreamObserver<Row> responseObserver) {
        Row row = Row.newBuilder().
                addCells(Cell.newBuilder().setKey("name").setValue("zgwserver").build())
                .addCells(Cell.newBuilder().setKey("sex").setValue("unknown").build())
                .build();
        responseObserver.onNext(row);
        responseObserver.onCompleted();


    }

    @Override
    public void saveRow(Row request, StreamObserver<Row> responseObserver) {
        request.getCellsList().forEach(cell -> {
            System.out.println(cell.getKey() + " : " + cell.getValue());
        });
        responseObserver.onNext(request);
        responseObserver.onCompleted();
    }

    @Override
    public void getDataSet(DBInfo request, StreamObserver<DataSet> responseObserver) {
        super.getDataSet(request, responseObserver);
    }

    @Override
    public void setDataSet(DBInfo request, StreamObserver<Reply> responseObserver) {
        super.setDataSet(request, responseObserver);
    }

    @Override
    public void saveDataSet(DBInfo request, StreamObserver<Reply> responseObserver) {
        super.saveDataSet(request, responseObserver);
    }
}
